package com.woniuxy.service.Impl;

import com.woniuxy.dao.MyuserDao;
import com.woniuxy.entity.UserDaikuanDate;
import com.woniuxy.entity.UserYewuDate;
import com.woniuxy.service.MyUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;

@Service
public class MyUserServiceImpl implements MyUserService {
    @Autowired
    MyuserDao myuserDao;
    @Override
    public List<UserYewuDate> listyewu(int id) {
        List<UserYewuDate> alllist = myuserDao.listyewu(id);
        for (UserYewuDate date:alllist) {
           date.setUser_name(date.getUserDate().getNickName());
        }
        return alllist;
    }

    @Override
    public List<UserDaikuanDate> listdaikuan(int id) {
        List<UserDaikuanDate> alllist = myuserDao.listdaikuan(id);
        for (UserDaikuanDate date:alllist) {
            date.setBenjin(date.getUserYewuDate().getLoan_amount());
            date.setLixi((date.getUserYewuDate().getLoan_rate()*date.getBenjin())/100);
            date.setZonge(date.getBenjin()+date.getLixi());
        }
        return alllist;
    }

    @Override
    public List<UserDaikuanDate> querydaikuan(Date[] datas,int id) {
        List<UserDaikuanDate> alllist = myuserDao.querydaikuan(datas,id);
        for (UserDaikuanDate date:alllist) {
            date.setBenjin(date.getUserYewuDate().getLoan_amount());
            date.setLixi((date.getUserYewuDate().getLoan_rate()*date.getBenjin())/100);
            date.setZonge(date.getBenjin()+date.getLixi());
        }
        return alllist;
    }

    @Override
    public List<UserYewuDate> queryyewu(Date[] datas, int id) {
        List<UserYewuDate> alllist = myuserDao.queryyewu(datas,id);
        for (UserYewuDate date:alllist) {
            date.setUser_name(date.getUserDate().getNickName());
        }
        return alllist;
    }
}
